<?php defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

/* JoomLeague League Management and Prediction Game for Joomla!
 * Copyright (C) 2007  Robert Moss
 *  
 * Homepage: http://www.joomleague.de
 * Support: htt://www.joomleague.de/forum/
 * 
 * This file is part of JoomLeague.
 *  
 * JoomLeague is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * Please note that the GPL states that any headers in files and
 * Copyright notices as well as credits in headers, source files
 * and output (screens, prints, etc.) can not be removed.
 * You can extend them with your own credits, though...
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * The "GNU General Public License" (GPL) is available at
 * http://www.gnu.org/copyleft/gpl.html.
*/ 
require $mosConfig_absolute_path.'/components/com_joomleague/images/joomleague/Thumb.class.php';
?>

<script language="javascript" type="text/javascript" src="<?=$mosConfig_live_site;?>/includes/js/overlib_mini.js"></script>
  <script language="javascript">
  
    function searchPlayer(val){
      var f = document.adminForm;
      if(f){
        f.elements['search'].value = val;
        f.submit();
      }
    }
  
  </script>

<form action="index2.php" method="post" name="adminForm">
<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
<div id="right">
	<div id="rightpad">
	
<!-- Header START -->	
		<div id="step">
			<div class="t">
        <div class="t">
          <div class="t"></div>
        </div>
      </div>
      <div class="m" align="left">
				<div class="far-right">
							<div class="button1-left"><div class="help"><a href="http://www.joomleague.de/handbuch.html" alt="<?php echo _JL_ADMIN_MANUAL;?>" title="<?php echo _JL_ADMIN_MANUAL;?>" target="blank"><?php echo _JL_ADMIN_MANUAL;?></a></div></div>
							<div class="button1-left"><div class="forum"><a href="http://www.joomleague.de/forum/" alt="<?php echo _JL_ADMIN_FORUM;?>" title="<?php echo _JL_ADMIN_FORUM;?>" target="blank"><?php echo _JL_ADMIN_FORUM;?></a></div></div>
							<div class="button1-left"><div class="about"><a href="http://www.joomleague.de" alt="<?php echo _JL_ADMIN_INFO;?>" title="<?php echo _JL_ADMIN_INFO;?>" target="blank"><?php echo _JL_ADMIN_INFO;?></a></div></div>
				</div>
				<div class="button1-left"><div class="blank"><a href="index2.php?option=com_joomleague"></a></div></div><span class="step"><?php echo _JL_ADMIN_EDIT_LIST_PLAYERS_LIST_PLAYERS;?></span>
			</div>
      <div class="b">
        <div class="b">
          <div class="b"></div>
        </div>
      </div>
    </div>
<!-- Header END -->     

    <div id="installer">
    
<!-- Title START -->     
			<div class="t">
        <div class="t">
          <div class="t"></div>
        </div>
      </div>
      <div class="m" align="left">
      	<h2><?php echo _JL_ADMIN_EDIT_LIST_PLAYERS_TITLE;?></h2>		
<!-- Titel END -->

<!-- Info START -->	 			
		<div id="step">
			<div class="t">
        <div class="t">
          <div class="t"></div>
        </div>
      </div>
      <div class="m" align="left">
<table class="content" cellpadding="4">
 <tr>
  <td><?php echo _JL_ADMIN_EDIT_LIST_PLAYERS_HINT1;?>
  </td>
 </tr>
</table>
			</div>
      <div class="b">
        <div class="b">
          <div class="b"></div>
        </div>
      </div>
    </div>
<!-- Info END -->

<!-- Navigation, Search etc. START -->   			
		<div id="step">
			<div class="t">
        <div class="t">
          <div class="t"></div>
        </div>
      </div>
      <div class="m" align="left">
<table class="content" cellpadding="4">
 <tr>

        <td>
        <?php echo _JL_ADMIN_EDIT_LIST_PLAYERS_SEARCH;?><input type="text" name="search" value="<?php echo $search;?>" class="inputbox" onChange="document.adminForm.submit();" />
      </td>
            <td align="center" colspan="4">
<?php
        for($i = 65; $i < 91; $i++){
          printf("<a href=\"javascript:searchPlayer('%s')\">%s</a>&nbsp;&nbsp;&nbsp;&nbsp;",chr($i),chr($i));
        }        
?>      &nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:searchPlayer('');"><?php echo _JL_ADMIN_EDIT_LIST_PLAYERS_ALL;?></a>
      </td>
  <td align="right" valign="center" nowrap><?php echo _JL_ADMIN_EDIT_LIST_PLAYERS_DISPLAY;?><?php echo $pageNav->writeLimitBox(); ?></td>
 </tr>
</table>
			</div>
      <div class="b">
        <div class="b">
          <div class="b"></div>
        </div>
      </div>
    </div>
<!-- Navigation, Search etc. END -->     
  	
<!-- Content START -->				
				<div class="install-text2">
	<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist2">
  	<thead>
    <tr>
      <th width="20"><input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $rows ); ?>);" /></th>
      <th>&nbsp;</th>
<?php /*
      <th>&nbsp;</th>
*/ ?>
      <th width="20">&nbsp;</th>
<th class="title" width="20%" nowrap="nowrap"><?php echo _JL_ADMIN_EDIT_FORM_PLAYERS_FIRSTNAME;?></th>
      <th class="title" width="25%" nowrap="nowrap"><?php echo _JL_ADMIN_EDIT_FORM_PLAYERS_LASTNAME;?></th>
      <th class="title" width="10%" align="right"><?php echo _JL_ADMIN_EDIT_FORM_PLAYERTOOL_POSITION;?></th>
      <th class="title" width="5%" nowrap="nowrap"><?php echo _JL_ADMIN_EDIT_LIST_PLAYERS_BIRTHDAY;?></th>
      <th class="title" width="30" nowrap="nowrap"><?php echo _JL_ADMIN_EDIT_FORM_PLAYERTOOL_HEIGHT;?></th>
      <th class="title" width="30" nowrap="nowrap"><?php echo _JL_ADMIN_EDIT_FORM_PLAYERTOOL_WEIGHT;?></th>
      <th class="title" width="20%" nowrap="nowrap"><?php echo _JL_ADMIN_EDIT_LIST_PLAYERS_COUNTRY;?></th>
      <th class="title" width="20%" nowrap="nowrap"><?php echo _JL_ADMIN_EDIT_LIST_PLAYERS_HISTORY;?></th>
    </tr>
  	</thead>
  <?php
  $k = 0;
  for ($i=0, $n=count( $rows ); $i < $n; $i++) {
       $row = &$rows[$i];
       $inputappend='';
       mosMakeHtmlSafe($row);
       $link = 'index2.php?option=com_joomleague&act=players&task=edit&cid[]='. $row->id;
       $checked = mosCommonHTML::CheckedOutProcessing( $row, $i );
              
       ?>
       <tr class="<?php echo "row$k"; ?>">
        <td width="20">
		<?php echo $checked;
		if ($row->checked_out == $my->id || strtolower($my->usertype) == 'super administrator') { ?>
		  <input type="checkbox" id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $row->id;?>" style="display:none" />
<?php }	?>
        </td>
        <td width="20">
        <?php
				if ( $row->checked_out && ($row->checked_out != $my->id && strtolower($my->usertype) != 'super administrator') ) {
				  $inputappend=' disabled="disabled"'
					?>&nbsp;
					<?php
					} else { 			
       ?>
       <a href="<?php echo $link; ?>">
          <img src="<?php echo $mosConfig_live_site;?>/components/com_joomleague/frontend/default/images/edit.png" border="0" alt="<?php echo _JL_EDIT_DETAILS;?>" title="<?php echo _JL_EDIT_DETAILS;?>"></a>
        </a>
        <?php } ?>
      </td>
      <td>
      <?php echo $row->id; ?>
      </td>
<?php /*
        <td width="20">
<?php
if ($row->default_picture!=''&&!is_null($row->default_picture)&&file_exists($mosConfig_absolute_path.'/'.$row->default_picture)) {

$Thumb = new PowerThumb();
$Thumb->setSrc($mosConfig_live_site.'/'.$row->default_picture);
$Thumb->setDescription($row->info);
$Thumb->setAlt($row->firstname." ".$row->lastname);
$Thumb->setMaxHeight(30);
$Thumb->setAmpliationLink(false);
//$Thumb->setFilter("gray");
$Thumb->create();

//echo '<img src="'.$mosConfig_live_site.'/'.$row->default_picture.'" alt="" height="30" />';
}
?></td>
<?php */ ?>
        <td>
            <input<?php echo $inputappend;?> type="text" size="10" class="inputbox" name="firstname<?php echo $row->id;?>" value="<?php echo $row->firstname;?>" onchange="document.getElementById('cb<?=$i;?>').checked=true" />
        </td>
        <td>
            <input<?php echo $inputappend;?> type="text" size="20" class="inputbox" name="lastname<?php echo $row->id;?>" value="<?php echo $row->lastname;?>" onchange="document.getElementById('cb<?=$i;?>').checked=true" />
        
        </td>
        <td nowrap="nowrap"><?php 
        $append='';
        if ($row->default_position_id==0) $append=' style="background-color:#bbffff"';
        echo mosHTML::selectList( $positions, 'default_position_id'.$row->id, 'class="inputbox"'.$inputappend.' size="1" onchange="document.getElementById(\'cb'.$i.'\').checked=true"'.$append,'value', 'text', $row->default_position_id ); ?>&nbsp;
        </td>
        <td nowrap="nowrap">
        <input<?php echo $inputappend;?> type="text" size="10" class="inputbox" name="birthday<?php echo $row->id;?>" value="<?php echo $row->birthday;?>" onchange="document.getElementById('cb<?=$i;?>').checked=true" />
          <?php 
          //printf("%s (%s)", mbiFormatDate($row->birthday, _JL_DAYDATE), getAge($row->birthday)); 
          ?>&nbsp;
        </td>
        <td>
        <input<?php echo $inputappend;?> type="text" size="3" class="inputbox" name="default_height<?php echo $row->id;?>" onchange="document.getElementById('cb<?=$i;?>').checked=true" value="<?php echo $row->default_height;?>" />
        </td>
        <td>
        <input<?php echo $inputappend;?> type="text" size="3" class="inputbox" name="default_weight<?php echo $row->id;?>" onchange="document.getElementById('cb<?=$i;?>').checked=true" value="<?php echo $row->default_weight;?>" />
        </td>
        <td>
        <?php
        $append='';
        if ($row->nation==0) $append=' style="background-color:#bbffff"';
        $query="SELECT countries_iso_code_3 FROM #__joomleague_countries WHERE countries_id = $row->nation";
        $database->setQuery($query);
        $result = $database->loadResult();
        if ($inputappend == '') { ?>
          <a href="javascript:void(0)"><span id="ctext<?php echo $row->id;?>"<?php echo $append;?> onclick="return overlib(document.getElementById('country<?php echo $row->id;?>').innerHTML, CAPTION,'COUNTRY:' , BELOW, LEFT,FOLLOWMOUSE=false, CLOSEBTN=true, CLOSEBTNCOLORS=['white', 'white', 'white', 'white'], STICKY=false);document.getElementById('mynation').options[document.getElementById('mynation').selectedIndex].value='<?php echo $row->nation;?>';" onmouseout="return nd();"><?php
          
          echo ($result) ? $result : 'SELECT'; ?>&nbsp;</span></a>
          <div id="country<?php echo $row->id;?>" style="position:absolute; visibility:hidden; z-index:1000;"><?php
          
          echo mosHTML::selectList( $countries, 'tempnation'.$row->id, 'class="inputbox" size="1" id="country'.$row->id.'" onchange="document.getElementById(\'ctext'.$row->id.'\').firstChild.nodeValue=this[this.selectedIndex].text+\'*\';document.getElementById(\'nation'.$row->id.'\').value=this[this.selectedIndex].value;document.getElementById(\'cb'.$i.'\').checked=true"','value', 'text', $row->nation );?>
          </div>
          <input type="hidden" name="nation<?php echo $row->id;?>" id="nation<?php echo $row->id;?>" value="<?php echo $row->nation;?>" />
<?php }
       else { 
        echo $result;
      }
        ?>
        
        </td>
        <td>
          <img align="top" src="components/com_joomleague/images/information.png" alt="Information" title="Information" width="16" height="16" onmouseover="return overlib(document.getElementById('plinfo<?php echo $row->id;?>').innerHTML, CAPTION,'INFOS:' , ABOVE, LEFT,FOLLOWMOUSE=false, CLOSEBTN=true, CLOSEBTNCOLORS=['white', 'white', 'white', 'white'], STICKY=false)" />
          <div id="plinfo<?php echo $row->id;?>" style="position:absolute; visibility:hidden; z-index:1000;"><?php
          echo $playerinfos[$row->id];?>
          </div>
        </td>
     </tr>
<?php
      $k = 1 - $k;
    } ?>
			<tr>
				<th align="center" colspan="12"><?php echo $pageNav->writePagesLinks(); ?></th>
			</tr>
			<tr>
				<td align="center" colspan="12"><?php echo $pageNav->writePagesCounter(); ?></td>
			</tr>
		</table>
				</div>
<!-- Content END -->	
			<input type="hidden" name="option" value="<?php echo $option; ?>" />
<input type="hidden" name="act" value="<?php echo $act; ?>" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
</form>
        <div class="clr"></div>
      </div>
      <div class="b">
        <div class="b">
          <div class="b"></div>
        </div>
      </div>
		</div>
	</div>
</div>
<div class="clr"></div>

